﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
namespace QuanLyNhaHang
{
    public partial class BaoCaoThongKe : Form
    {
        DataTable Source = new DataTable();
        DataTable MonAn = new DataTable();
        public BaoCaoThongKe()
        {
            InitializeComponent();
        }
        private void LayMonAn()
        {
            MonAn = BUSBaoCao.MonAn();
            DataRow newrow = MonAn.NewRow();
            newrow[0] = "emp";
            newrow[1] = "Chọn Món Ăn";
            newrow[2] = "";
            newrow[3] = -1;
            newrow[4] = 0.0;
            MonAn.Rows.InsertAt(newrow, 0);
            comboBox_monan.DataSource = MonAn;
            comboBox_monan.DisplayMember = "TenMonAn";
            comboBox_monan.ValueMember = "MaMonAn";
        }
        private void button_baocao_Click(object sender, EventArgs e)
        {
            if (radioButton_ngay.Checked == true)
            {
                Source = BUSBaoCao.KetQuaLocTheoNgay(dateTimePicker_ngay.Value);
                Source.TableName = "BaoCao";
                var obj = new RPBaoCao();
                obj.SetDataSource(Source);
                obj.SetParameterValue("Ngay", dateTimePicker_ngay.Value);
                crystalReportViewer1.ReportSource = obj;
            }
            if (radioButton_monan.Checked == true)
            {
                string ma = comboBox_monan.SelectedValue.ToString().Trim();
                if(ma != "emp")
                {
                    Source = BUSBaoCao.KetQuaLocTheoMon(ma);
                    Source.TableName = "BaoCao";
                    var obj = new RPBaoCao();
                    obj.SetDataSource(Source);
                    crystalReportViewer1.ReportSource = obj;
                }
            }
        }

        private void button_thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void BaoCaoThongKe_Load(object sender, EventArgs e)
        {
            LayMonAn();
        }
    }
}
